package com.explorati.LeetCode222.countcompletetreenodes;

/**
 * 222. Count Complete Tree Nodes
 * 
 * @author explorati
 *
 */
public class Solution {
	public class TreeNode {
		int val;
		TreeNode left;
		TreeNode right;

		TreeNode(int x) {
			val = x;
		}
	}

	int num = 0;

	public int countNodes(TreeNode root) {
		if (root == null) {
			return 0;
		}

		num++;
		countNodes(root.left);
		countNodes(root.right);
		return num;
	}
}
